import { defineConfig } from "vite";
import vuePlugin from "@vitejs/plugin-vue";
import path from "path";

// https://vitejs.dev/config/
export default defineConfig({
  base: "/",
  server: {
    port: 8000,
    strictPort: true,
    proxy: {
      "/api": {
        target: "http://47.120.15.201:3000",
        // target: "https://api.zhangwurui.cn",
        changeOrigin: true,
        // rewrite: path => path.replace(/^\/api/, "")
      }
    },
  },
  resolve: {
    alias: {
      // https://github.com/vitejs/vite/issues/1363
      "@": path.resolve(__dirname, "src")
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        // https://github.com/vitejs/vite/issues/520
        additionalData: `@import "./src/styles/variables.scss"; @import "./src/styles/mixins.scss";`
      }
    }
  },
  plugins: [
    vuePlugin()
  ],
  optimizeDeps: {
    include: [
      "swiper",
      "highlight.js/lib/core",
      "highlight.js/lib/languages/css",
      "highlight.js/lib/languages/sql",
      "highlight.js/lib/languages/xml",
      "highlight.js/lib/languages/json",
      "highlight.js/lib/languages/bash",
      "highlight.js/lib/languages/less",
      "highlight.js/lib/languages/scss",
      "highlight.js/lib/languages/shell",
      "highlight.js/lib/languages/nginx",
      "highlight.js/lib/languages/python",
      "highlight.js/lib/languages/javascript",
      "highlight.js/lib/languages/typescript",
    ],
    exclude: [
      "highlight.js"
    ]
  },
  build: {
    minify: false,
    outDir: "./www.zhangwurui.cn",
    assetsDir: "static"
  }
})
